package controller.record;

import pojo.view.MRecord;
import service.RecordService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "MGetRecordController", value = "/MGetRecordController")
public class MGetRecordController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        RecordService service = new RecordService();
        // get unUsed
        List<MRecord> unUsedRecords = service.getUnUsed();
        // get in use
        List<MRecord> inUseRecords = service.getInUse();
        // get completed
        List<MRecord> completedRecords = service.getCompleted();

        request.setAttribute("unUsedRecords", unUsedRecords);
        request.setAttribute("inUseRecords", inUseRecords);
        request.setAttribute("completedRecords", completedRecords);

        request.getRequestDispatcher("/view/manager/record/record.jsp").forward(request, response);
    }
}
